﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using System.Reflection;

namespace YhmOA.Common
{
    /// <summary>
    /// 注意下面的语句一定要加上，指定log4net使用.config文件来读取配置信息
    /// </summary>
    [assembly: log4net.Config.XmlConfigurator(Watch = true)]
    public static class Log
    {
        #region Variables and Properties
        private static ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        #endregion

        #region Public Method
        /// <summary>
        /// 记录一般信息
        /// </summary>
        /// <param name="message">信息文本</param>
        /// <param name="exception">异常</param>
        public static void Info(object message, Exception exception)
        {
            log.Info(message, exception);
        }

        /// <summary>
        /// 记录一般信息
        /// </summary>
        /// <param name="message">信息文本</param>
        public static void info(object message)
        {
            log.Info(message);
        }

        /// <summary>
        /// 记录调试信息
        /// </summary>
        /// <param name="message">信息文本</param>
        /// <param name="exception">异常</param>
        public static void Debug(object message, Exception exception)
        {
            log.Debug(message, exception);
        }

        /// <summary>
        /// 记录调试信息
        /// </summary>
        /// <param name="message">信息文本</param>
        public static void Debug(object message)
        {
            log.Debug(message);
        }

        /// <summary>
        /// 记录警告信息
        /// </summary>
        /// <param name="message">信息文本</param>
        /// <param name="exception">异常</param>
        public static void Warn(object message, Exception exception)
        {
            log.Warn(message, exception);
        }

        /// <summary>
        /// 记录警告信息
        /// </summary>
        /// <param name="message">信息文本</param>
        public static void Warn(object message)
        {
            log.Warn(message);
        }

        /// <summary>
        /// 记录错误信息
        /// </summary>
        /// <param name="message">信息文本</param>
        /// <param name="exception">异常</param>
        public static void Error(object message, Exception exception)
        {
            log.Error(message, exception);
        }

        /// <summary>
        /// 记录错误信息
        /// </summary>
        /// <param name="message">信息文本</param>
        public static void Error(object message)
        {
            log.Error(message);
        }

        /// <summary>
        /// 记录严重错误信息
        /// </summary>
        /// <param name="message">信息文本</param>
        /// <param name="exception">异常</param>
        public static void Fatal(object message, Exception exception)
        {
            log.Fatal(message, exception);
        }

        /// <summary>
        /// 记录严重错误信息
        /// </summary>
        /// <param name="message">信息文本</param>
        public static void Fatal(object message)
        {
            log.Fatal(message);
        }
        #endregion
    }
}